package com.shqcjd.yunweiyanoperator.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.yunweiyanoperator.R;
import com.shqcjd.yunweiyanoperator.model.pojo.ContactsNewsBean;

import java.util.List;

public class ContactsAddMsgAdapter extends BaseQuickAdapter<ContactsNewsBean, ContactsAddMsgAdapter.ViewHolder> {
    private Context context;

    public ContactsAddMsgAdapter(@Nullable List<ContactsNewsBean> data, Context context) {
        super(R.layout.item_contacts_msg, data);
        this.context = context;
    }

    @Override
    protected void convert(ViewHolder helper, ContactsNewsBean item) {
        helper.tv_contacts_phone.setText(item.businessName);
        helper.tv_contacts_name.setText(item.friendName);
        helper.tv_contacts_tag.setText(item.friendName.substring(0, 1));
        switch (item.friendStatus){
            case 1:
                helper.tv_contacts_type.setText("添加");
                helper.tv_contacts_type.setTextColor(Color.WHITE);
                helper.tv_contacts_type.setBackgroundResource(R.drawable.shape_login_bg);
                break;
            case 2:
                helper.tv_contacts_type.setText("已添加");
                helper.tv_contacts_type.setTextColor(Color.parseColor("#FF9E24"));
                helper.tv_contacts_type.setBackgroundResource(R.color.transparent);
                break;
            case 3:
                helper.tv_contacts_type.setText("已拒绝");
                helper.tv_contacts_type.setTextColor(Color.parseColor("#FF9E24"));
                helper.tv_contacts_type.setBackgroundResource(R.color.transparent);
                break;
        }
        helper.addOnClickListener(R.id.tv_contacts_type);
    }

    class ViewHolder extends BaseViewHolder {
        TextView tv_contacts_type, tv_contacts_phone, tv_contacts_name, tv_contacts_tag;
        public ViewHolder(View view) {
            super(view);
            tv_contacts_type = view.findViewById(R.id.tv_contacts_type);
            tv_contacts_phone = view.findViewById(R.id.tv_contacts_phone);
            tv_contacts_name = view.findViewById(R.id.tv_contacts_name);
            tv_contacts_tag = view.findViewById(R.id.tv_contacts_tag);
        }
    }
}
